

#include "atomic_op_namespace.h"

#if !defined(_KERNEL) && !defined(_STANDALONE)
#include <stdbool.h>
#endif
#include <sys/atomic.h>

bool __atomic_compare_exchange_1(volatile uint8_t *, uint8_t *, uint8_t,
    bool, int, int);

bool
__atomic_compare_exchange_1(volatile uint8_t *mem,
    uint8_t *expected, uint8_t desired,
    bool weak, int success, int failure)
{
	uint8_t old = *expected;

	/*
	 * Ignore the details (weak, memory model on success and failure)
	 * and just do the cas. If we get here the compiler couldn't
	 * do better and it mostly will not matter at all.
	 */
	return atomic_cas_8(mem, old, desired) == old;
}
